﻿using System.Globalization;
using System.Windows.Data;

namespace TimeSpan.ValueConverters;

/// <summary>空引用和布尔值转换器，如果为空则为true</summary>
[ValueConversion(typeof(object), typeof(bool))]
public class NullToBooleanConverter : IValueConverter {

    /// <summary>是否反转转换器</summary>
    public bool IsInverse { get; set; } = false;

    /// <inheritdoc/>
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
        return value is null ^ IsInverse;
    }

    /// <inheritdoc/>
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
        throw new NotImplementedException();
    }

}